package com.cn.ZhiKeDianShang.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cn.ZhiKeDianShang.R;
import com.cn.ZhiKeDianShang.base.BaseActivity;
import com.cn.ZhiKeDianShang.model.response.UserInfoBean;
import com.cn.ZhiKeDianShang.presenter.LoginUserPresenter;
import com.cn.ZhiKeDianShang.presenter.view.LoginUserView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/7/3.
 * do what to 2017/7/3
 */

public class ChangeSexNameActivity extends BaseActivity<LoginUserView, LoginUserPresenter> implements LoginUserView {


    @BindView(R.id.tv_left)
    TextView tvLeft;
    @BindView(R.id.im_man)
    ImageView imMan;
    @BindView(R.id.im_woman)
    ImageView imWoman;
    //保密
    String gender = "3";

    @Override
    protected int getNormalLayoutId() {
        return R.layout.activity_updatesex_info;
    }

    @Override
    protected int getErrorLayoutId() {
        return R.layout.activity_updatesex_info;
    }

    @Override
    protected LoginUserPresenter createPresenter() {
        return new LoginUserPresenter(this, this);
    }

    @Override
    protected void initViewsAndEvents() {
        gender = getIntent().getStringExtra("gender");
        if (gender.equals("1")) {
            imMan.setVisibility(View.VISIBLE);
            imWoman.setVisibility(View.GONE);
        } else if (gender.equals("2")) {
            imMan.setVisibility(View.GONE);
            imWoman.setVisibility(View.VISIBLE);
        } else {
            imMan.setVisibility(View.GONE);
            imWoman.setVisibility(View.GONE);
        }

    }

    @Override
    public void onLogin(UserInfoBean resultBean) {

    }

    @Override
    public void requestFailed(String message) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }


    @OnClick({R.id.setting_back, R.id.tv_left, R.id.rl_man, R.id.rl_woman})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.setting_back:
                finish();
                break;
            case R.id.tv_left:
                // 设置返回数据
                Bundle bundle = new Bundle();
                bundle.putString("gender", gender);
                Intent intent = new Intent();
                intent.putExtras(bundle);
                // 返回intent
                setResult(RESULT_OK, intent);
                finish();
                break;
            case R.id.rl_man:
                gender="1";
                imMan.setVisibility(View.VISIBLE);
                imWoman.setVisibility(View.GONE);
                break;
            case R.id.rl_woman:
                gender="2";
                imMan.setVisibility(View.GONE);
                imWoman.setVisibility(View.VISIBLE);
                break;
        }
    }
}
